<?php

class Usuario {

    static function ValidarStaUsu($id = 0) {
        
        $where = 'USU_ID = '.$id;
        
        $obj = new Ead_Model_DbTable_Usuarios();
        $row = $obj->fetchRow($where);
        
        if($row->USU_STA == 1) return 1;
        else return 0;
    }
    
    static function setIdSessaoUsu($id,$sessao) {
        $obj = new Ead_Model_DbTable_Usuarios();
        $obj->update(array('USU_SESSAO'=>$sessao), 'USU_ID = ' . $id);
        
        Zend_Auth::getInstance()->getStorage()->read()->USU_SESSAO = $sessao;
        
    }
    
    static function ValidarSessaoUsu() {
        
        $where = 'USU_ID = '.Zend_Auth::getInstance()->getStorage()->read()->USU_ID;
        
        $obj = new Ead_Model_DbTable_Usuarios();
        $row = $obj->fetchRow($where);
        
        if($row->USU_SESSAO == session_id()) return 1;
        else return 0;
        
    }
    
    static function ValidarStaCad($id = 0) {
        
        $where = 'USU_ID = '.$id;
        
        $obj = new Ead_Model_DbTable_Usuarios();
        $row = $obj->fetchRow($where);
        
        return $row->USU_STAEML;
    }
    
}